<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <title>服务归档</title>
    <base href=<%=basePath%>
    <%@include file="../common_css.jsp"%>
</head>
<body class="childrenBody">

<form class="layui-form" >
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="customer"
                           class="layui-input
					searchVal" placeholder="客户" />
                </div>
                <div class="layui-input-inline">
                    <select name="type"  id="type">
                        <option value="-1" >请选择</option>
                    </select>
                </div>

                <a class="layui-btn search_btn" data-type="reload"><i
                        class="layui-icon">&#xe615;</i> 搜索</a>
            </div>
        </form>
    </blockquote>

    <table id="customerServeList" class="layui-table"  lay-filter="customerServes"></table>


    <script type="text/html" id="toolbarDemo">
    </script>
    <script id="customerServeListBar" type="text/html">
        <a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs"  lay-event="info">详情</a>
    </script>
</form>
<script type="text/javascript">
    layui.use(['table','layer',"form"],function(){
        var layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            table = layui.table;

        //服务列表展示findCusDriveNotHandle
        table.render({
            elem: '#customerServeList',
            url : 'cusDrive/findCusDriveIsHandle',
            cellMinWidth : 95,
            page : true,
            height : "full-125",
            limits : [10,15,20,25],
            limit : 10,
            toolbar: "#toolbarDemo",
            id : "customerServeListTable",
            method : 'post',
            cols : [[
                {field: "id", title: '编号', fixed: "true", width: 80},
                {
                    field: 'customerName', title: '客户名', minWidth: 50, align: "center", templet: function (d) {
                        return d.customer.name;
                    }
                },
                {field: 'driveName', title: '试驾人姓名', minWidth: 100, align: 'center'},
                {field: 'stringDriveType', title: '试驾类型', align: 'center'},
                {field: 'carSeries', title: '汽车型号', minWidth: 100, align: 'center'},
                {field: 'driveTime', title: '试驾时间', align: 'center', minWidth: 150},
                {field: 'createTime', title: '创建时间', align: 'center', minWidth: 150},
                {title: '操作', templet: '#customerServeListBar', fixed: "right", align: "center", minWidth: 150}
            ]]
        });

        table.on('tool(customerServes)',function (obj) {
            var layEvent =obj.event;
            var title="服务归档-服务详情";
            var url="cusDrive/toDriveArchivePage?id="+$(this).parent().parent().siblings(":first").children().text();
            layui.layer.open({
                title:title,
                type:2,
                area:["700px","500px"],
                maxmin:true,
                content:url
            })
        });

        $.post("dictionaries/findDriveType",function (res) {
            for(var i=0;i<res.length;i++) {
                $("#type").append("<option value=\"" + res[i].valueId + "\"   >" + res[i].valueName + "</option>");
            }
            // 重新渲染下拉框内容
            layui.form.render("select");
        });
        // 多条件搜索
        $(".search_btn").on("click",function(){
            table.reload("customerServeListTable",{
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    customerName: $("input[name='customer']").val(),  //客户名
                    driveType: $("#type").val()  //服务类型
                },
                url : 'cusDrive/findCusDriveIsHandleConditional',
                contentType :'application/json'
            })
        });

    });

</script>

</body>
</html>
